/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.railway.utils;

import java.util.Comparator;
import java.util.Map;

/**
 *
 * @author Kenny
 */
public class MapSortHelper implements Comparator<Map<String, String>> {

    public final static int SORT_ASC = 0;
    public final static int SORT_DSC = 1;
    private int sortMode;

    public MapSortHelper(int sortMode) {
        this.sortMode = sortMode;
    }

    @Override
    public int compare(Map<String, String> o1, Map<String, String> o2) {
        Integer m1 = Integer.parseInt(o1.get("order"));
        Integer m2 = Integer.parseInt(o2.get("order"));
        return (sortMode == SORT_ASC ? m1.compareTo(m2) : m2.compareTo(m1));
    }
}

